var amqp = require('amqplib');
amqp.connect('amqp://127.0.0.1').then(function(conn) {
  process.once('SIGINT', function() {
    conn.close();
  });
  return conn.createChannel().then(function(ch) {
    var ok = ch.assertQueue('hello', {
      durable: false
    });

    ok = ok.then(function(_qok) {
      return ch.consume('hello', function(msg) {
        console.log(" [x] Received '%s'", msg.content.toString());
      }, {
        noAck: true
      })
    })
    return ok.then(function(_consumeOk) {
      console.log(' [*] Waiting for messages. To exit press CTRL + C ');
    });
  })
}).then(null, console.warn);